
<template>
    <div class="port-page">
        <!-- 顶部按钮 -->
         <div class="but1">
        <router-link to="/home">
         	<el-button type="warning" size="small"   style=' margin-right: 10px;'  icon="el-icon-menu">首页</el-button>
        </router-link>
         	<!--<el-button type="success" v-if="this.qxbtn.frmrskcjgaddyn" size="small" style=' margin-top:10px;margin-right: 10px;' @click='componentsShow("add")' icon="el-icon-edit">添加</el-button>-->

        </div>
        <!-- 模糊搜索条件 -->
        <div class="search">
        	<!--<el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss" @click='gd'>更多</el-button>
            <el-button type="text" size="small" class="add btn" style=' text-decoration:underline;' v-if="ss1" @click='gd1'>更多</el-button>
            <div class="search-item">
                <el-input placeholder="名称、电话搜索" class="code-search" v-model="vkeyword"  @keyup.enter.native="search" icon="search"></el-input>
            </div>
        <el-button type="primary" size="small" class="add btn" style="border-radius:13px ;" :loading="searchLoading" @click="search" icon="el-icon-search"></el-button>-->
        <el-input placeholder="请输入学生名称/电话"  v-model="vkeyword"  style="width: 300px;" @keyup.enter.native="search"  >
				<el-select v-model="select" slot="prepend"  style="width: 80px;">
					<el-option label="学生" value="1"></el-option>
					<el-option label="物品" value="2"></el-option>
				</el-select>
				<el-button slot="append" icon="el-icon-search" @click='search()' ></el-button>
			</el-input>
        </div>
        
        <!--<div class="search1" v-if='aa'>
        	<div class="search-item">
                <span>学生状态</span>
                <el-select v-model="vzt" @change="search" clearable class="code-search">
                	  <el-option label="在读" value="zd"></el-option>
                    <el-option label="休学" value="xx"></el-option>
                    <el-option label="退学" value="tx"></el-option>
                </el-select>
            </div> 
            <span>时间段</span>
        	<div class="search-item">
                <el-date-picker  v-model="vbtime"  type="date" :editable="false" class="code-search"  placeholder="开始日期" @keyup.enter.native="search" icon="search"></el-date-picker>
            </div>
        	<span>-</span>
        	<div class="search-item">
                  <el-date-picker  v-model="vetime"  type="date" :editable="false" class="code-search"  placeholder="结束日期" @keyup.enter.native="search" icon="search"></el-date-picker>
            </div>
        </div>-->
        <!-- 数据表格展示区域 -->
        <el-table
            :data="dataList"
            size="small"
			border 
			stripe 
            align="center"
            class="admin-table"
            >
            <!--<el-table-column type="selection" width="55"></el-table-column>-->
            <div slot='empty'>
                <!--<img src="@/assets/img/empty.png" style="width:40px;vertical-align: middle;">-->
                <!--<span style="vertical-align: middle;">暂时还没有这个学生哦!</span>-->
                <el-button type=""  @click="componentsShow('bujiao')" >报名添加</el-button>
            </div>
            <el-table-column
                :prop="v.prop"
                :label="v.label"
                v-for="(v,index) in portTitleList"
                align="center"
                show-overflow-tooltip
                v-if="v.hide != 0"
                :formatter="v.formatter"
                :align="v.align || 'center'"
                :fixed="v.fixed"
                :class-name="v.columnStyle"
                :width="v.width"
                :min-width="v.minWidth"
                :header-align="v.headerAlign || 'center'"
                >
                <template scope="scope">
                    <div slot="reference" :style="tableCellControl(scope)">
                        {{ scope.row[scope.column.property] }}
                    </div>
                 </template>
                 <template scope="scope">
                    <div slot="reference" >
                        <div v-if="scope.column.property == 'zwm'" @click="componentsShow('info',scope)">
                            <img :src="scope.row.xb == '男' ? $store.state.sexImg.boy : $store.state.sexImg.girl"
                            style="width:20px;vertical-align:middle; float: left;"
                            v-if="scope.column.property == 'zwm'">
                            <span style="vertical-align:middle;">{{ scope.row[scope.column.property] }}</span>
                        </div>
                        <span style="vertical-align:middle;" v-else>{{ scope.row[scope.column.property] }}</span>
                    </div>
                </template>
            </el-table-column>
			<el-table-column label="操作"  width="120px" align="center">
                <template scope="scope">
                    <el-button size="small" type="primary"  @click="xsxq(scope.row.id,scope)" >操作</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!-- 分页查询区域 -->
        <!--<el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="pageindex"
            :page-sizes="pagesizes"
            :page-size="pagesize"
            :layout="layout"
            :total="total"
            class="class-page">
        </el-pagination>-->
        <!-- 各个组件显示区域 -->
        <!-- 动画加载 -->
        <!--<LoadingComponent v-show="isLoading"></LoadingComponent>-->
        <infoComponent v-if="portComponents.info.toggle" @close="componentsHide" :params="portComponents.info.params"></infoComponent>
		<BujiaoComponent v-if="portComponents.bujiao.toggle" @close="componentsHide" :params="portComponents.bujiao.params" ></BujiaoComponent>
        <!-- 添加组件 -->
        <!-- 子路由显示区域 -->
        <router-view class="port-view"></router-view>
    </div>
</template>
<script>
    import { mapState } from 'vuex'
    import qs from 'qs'
    import InfoComponent from '@/view/educa/classManage/student/info'
    import BujiaoComponent from '@/view/cost/baoming/add'
    export default {
    	props: ['params'],
        components: { 
        	InfoComponent,BujiaoComponent},
        data () {
            return {

            /*模糊搜索条件*/
           		select:'1',
           		aa:false,
			    ss:true,
			    ss1:false,
                vzt:'',
                vbtime:'',
                vetime:'',
               
               vkeyword:'', // keyword

				multipleDelNum:'', //获取批量选择的数据
                dataList: [],  //表格数据
                comboxlist:[], //下拉框 动态的
                vcomautovalue:'',//下拉框name 动态的
                vcomgdvalue:'',//下拉框name 固定的

                /*分页属性设置*/
                layout: 'total, sizes, prev, pager, next, jumper',//组件布局
			    pageindex: this.$store.state.pageindex,//当前分页页码
                pagesizes: this.$store.state.pagesizes,//显示个数的选择器选项
                pagesize: this.$store.state.pagesize,//每页显示条目数
                total: 0,//总条数

                /*组件区域*/
                portComponents: {
                    info: {
						type: 'info',
						toggle: false,
						params: '',
						data: {}
					},
					bujiao: {
                        type: 'bujiao',
                        toggle: false,
                        params: '',
                        data: {}
                    },
                },
                /*
                    prop :  接口参数名
                    label : 接口中文名
                    hide : 是否隐藏这一列
                    align : 这一列对齐顺序 ： left,right,center
                    headerAlign : 这一列表头对齐方式 ： left,right,center
                */
                portTitleList: [

                    {
                        prop:'id',
                        label:'学生id',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'zwm',
                        label:'学生名称',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'dh',
                        label:'电话',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'bjmc',
                        label:'班级名称',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'zt',
                        label:'在校状态',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'zcsj',
                        label:'入校时间 ',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'ycje',
                        label:'预存金额',
                        hide:0,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'syks',
                        label:'剩余课时',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    } ,
                    {
                        prop:'qf',
                        label:'欠费金额',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    },
                    {
                        prop:'wlqwp',
                        label:'未领取物品',
                        hide:1,
                        align:'center',
                        fixed:false,
                        width:'',
                        minWidth:'',
                        headerAlign:'center',
                        formatter: function(row,column) {}
                    }

                ]
            }
        },
        created () {
            this.$store.dispatch('changeTitle','学生信息');//修改title
            this.$store.dispatch('changeRouterIndex','/home');//修改路由
            console.log(this.$route.query.xsxx)
        	this.vkeyword = this.$route.query.xsxx
            this.search();//分页获取默认数据
        },
        mounted () {
        },
        methods: {
        	gd(){
        		this.aa=true;
        		this.ss=false;
        		this.ss1=true;
        	},
        	gd1(){
        		this.aa=false;
        		this.ss=true;
        		this.ss1=false;
        	},
        	xsxq(id,list){
        		this.$router.push({ name: 'syxsinfo', query: { iid:id,frompage:list }})
        	},
          search () {
		    //查询搜索触发事件
		    var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                      keyword: this.vkeyword, // keyword
                      yhid:logininfo.id,
                      xxid:logininfo.xxid,
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xs/xssyselect',  params2 )
                 .then(res => {
                 	console.log(res,5656)
                  let data = res.data.data;
                  let list = data.list;
                  this.dataList = list;
                 }).catch(res => {
                  this.searchLoading = false;
				})
          },
          tableCellControl (scope) {
            //表格单元格控制CSS样式
                /*if (scope.row.id == 112 && scope.column.property == "iname") {
                    return {
                        color:"red",
                    }
                }else{
                    return {
                        color:"green",
                    }
                }*/
           },
//         handleSizeChange (val) {//每页显示条数触发事件
//              this.pagesize = val;
//              this.pageindex = 1;
//              this.search();
//          },
//          handleCurrentChange (val) {//分页触发事件
//              this.search();
//          },
//          checkSelect (selection, row) {//点击单选select触发事件
//              console.log(selection, row)
//              let strID = [];
//              selection.forEach(function(v,i){
//                  strID.push(v.id)
//              })
//              this.multipleDelNum = strID.join(",");
//          },
//          checkall (selection) {//点击全选select触发事件
//              let strID = [];
//              selection.forEach(function(v,i){
//                  strID.push(v.id)
//              })
//              this.multipleDelNum = strID.join(",");
//          },
            /* 组件的弹框  */
            componentsShow (type,data) { //显示组件
                console.log(type,data)
                for ( let i in this.portComponents ) {
                    if (type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = true;
                        this.portComponents[i].params = data;
                        if (this.portComponents[i].data.type == 'single') {
                            this.portComponents[i].data.index = data.row.id
                        }else if(this.portComponents[i].data.type == 'multiple'){
                            this.portComponents[i].data.index = this.multipleDelNum;
                        }else{
                            return;
                        }
                        return;
                    }
                }
            },
            componentsHide (setting) { //关闭组件
                for ( let i in this.portComponents ) {
                    if (setting.type == this.portComponents[i].type) {
                        this.portComponents[i].toggle = false;
                        if (!setting.cancel) {
                           this.search();
                        }
                        return;
                    }
                }
            }
        },
        computed: {
            ...mapState([
                'api'//域名
            ]),
            multipleDeleteDisabled () {
                if (this.multipleDelNum) {
                    return false;
                }else{
                    return true
                }
            }
        }
    }
</script>

<style lang="less" scoped>
    .port-page {
        font-size:12px;
        .btn {
            height: 30px;
            padding:0 10px;
        }
        .code-search {
             max-width: 130px;
            min-width: 100px;
            text-align: center;
            height: 50px;
            /*line-height: 50px;*/
            font-size: 12px;
        }
        .class-page {
            text-align: left;
            margin-top:10px;
        }
        .search-item {
            display: inline-block;
            /*margin-right:10px;*/
        }
        .el-button+.el-button {
    margin-left: 5px;
}
        .but1{
			width: 30%;
			height: 50px;
			float: left;
			line-height: 50px;
		}
		.search{
			width: 70%;
			height: 50px;
			line-height: 50px;
			float: right;
			text-align: right;
		}
		.search1{
			width: 50%;
			height: 50px;
			float: right;
			line-height: 50px;
			margin-right: 36px;
			text-align: right;
		}
    }
</style>
